function saveSubData
% Step through all text files, parsing, and then saving to the data folder.


files = rdir('/Volumes/300GB iceCUBE G2/DataEmotion/LoudnessExp/**/');
whoarethey =0;
for j = 1:length(files)
  % This is the parser for the particular text file. It will be
  % different for each text file.
  
  % Find the text file only.
  if strfind(files(j).name,'.txt');
    
    % Read the text file and get a list of the sdata files to look at and
    % their associated audio file for analysis
    disp(files(j).name);
    list = readInstructionsTextFile(files(j).name);
    id = readDemographics(files(j).name);
    if isstr(id)
      whoarethey = whoarethey+1;
      continue;
    end
    for i = 1:length(list)-1
      
      if ~isempty(dir(list{i+1,1}))
        
        ts                               = parseDataFile(list{i+1,1},list{i+1,2});
        ts.DataInfo.UserData.Fam         = list{i+1,4};
        ts.DataInfo.UserData.Pref        = list{i+1,5};
        ts.DataInfo.UserData.PresOrder   = list{i+1,6};
        ts.DataInfo.UserData.Gender      = id.gender;
        ts.DataInfo.UserData.MusTraining = id.mus;
        ts.DataInfo.UserData.Age         = id.age;
        
        % This method is inside PsySound3, and saves a ts object to the
        % PsySoundData folder inside a folder called SubjectiveData under the
        % appropriate audiofile folder.
        fprintf('%s %s %s\n',list{i+1,1},list{i+1,2},list{i+1,3});
        addSubjectiveData(ts,ts.DataInfo.UserData.audiofn);
      end
    end
  end
end
whoarethey

